package com.zjb.wxlisener.control;

import com.zjb.wxlisener.JavaBean.Result;
import com.zjb.wxlisener.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/collect")
public class CollectControl {
    @Autowired
    CollectService collectService;
    @GetMapping("/status")
    public Result likeStatus(Integer id){
        Boolean status = collectService.likeStatus(id);
        return Result.success(status);
    }
    @GetMapping("/update")
    public Result updateCounts(Integer id,Integer musiclikes,String openid){
        try {
            collectService.uptateCounts(id,musiclikes);
            collectService.addUserCollect(id,openid);
        }catch (Exception e){
            return Result.error("有误");
        }
        return  Result.success();
    }
}
